home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
MCASM.RAR
/
MC_ASM.EXE
/
WROX_ASM
/
CH12
/
COMMON
/
MAPPER.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-24
|
2KB
|
68 lines
#ifndef mapper_h
#define mapper_h
/*
* Covert a TrueColor image into "splitted colors" (regular) palette
* based on variant of Floid-Stainberg algorithm
* Some details and most of ideas were borrowed
* from the Independent JPEG Group's software.
* ( see the accompanying README file).
* E.Podvoysky from ^Z for WROX press book
*/
class color_mapper {
protected:
// are allocated used only for dithering
BOOL on_odd_row;
int *error[3],*next_line_error[3]; // R,G and B, size = width+2
public:
BOOL initialized;
BGRpalette my_colormap; /* output colormap */
int actual_number_of_colors,width;
color_mapper() {};
color_mapper(int colors_,int width_,BGRpalette colormap);
virtual ~color_mapper();
int prepare_dithering(); // - 1 if not enough memory
virtual void process_line(BYTE *R, BYTE *G, BYTE *B, BYTE *out_line) {};
};
class color_mapper_splitted: public color_mapper {
protected:
BYTE *convert_table[3], // convert input value to (partial) color index
// input range from 0 to 2*max_color_value
*value_table[3], // values of color componente by index
color_num[3],
*convert_table0[3]; //actual pointers on allocated arrays!
int max_color_value;
void init(int width_, BYTE *color_values[3], BYTE color_num_[3]); //sub proc. for constructors
// for gray and splitted colors :
// preapare table to convert input value to (partial) color #
virtual void prepare_table(BYTE *values,int color_index);
int select_colors_num(int max_colors);
// returns (-1) if max_colors is bad
virtual void process_one_color(BYTE *in, BYTE *out_line, int col_ind);
public:
color_mapper_splitted() {};
color_mapper_splitted(int width_, BYTE *color_values[3], BYTE color_num_[3]);
color_mapper_splitted(int colors_,int width_,int max_color_value_); //short cut
virtual ~color_mapper_splitted();
virtual void process_line(BYTE *R, BYTE *G, BYTE *B, BYTE *out_line);
};
class color_mapper_gray: public color_mapper_splitted {
public:
color_mapper_gray(int colors_,int width_,int max_color_value_);
color_mapper_gray() {}; // formal
virtual void one_row(BYTE *source, BYTE *out_line);
};
#endif